import entity.StudentDTO;
import entity.student;

import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class ListTest {
    public static void main1(String[] args) {

        Long hhh = 1234567L;
        System.out.println(hhh.toString());


        StudentDTO studentDTO = new StudentDTO();
        List<student> students = new ArrayList<>();
        students.add(new student("张三", "男", 18, 8801));
        students.add(new student("李四", "男", 18, 8802));
        students.add(new student("王五", "女", 20, 8803));
        students.add(new student("赵六", "女", 20, 8804));
        students.add(new student("七七", "女", 21, 8805));
        studentDTO.setStudentList(students);
        studentDTO.getStudentList().add(new student("test","nan",20,890));
        System.out.println("大小   ："+studentDTO.getStudentList().size());
        System.out.println(students.get(0));
        System.out.println("=======================");
        List<student> test = new ArrayList<>();
        System.out.println(test.toString());
        if (test.size() == 0 ){
            System.out.println("为空");
        }
        System.out.println("=======List流操作去重复=======");
        List<String> nameList = new ArrayList<>();
        nameList.add("刘");
        nameList.add("刘");
        nameList.add("刘");
        nameList.add("刘");
        nameList.add("刘");
        nameList.add("刘");
        nameList.add("李");
        nameList.add("李");
        nameList.add("李");
        nameList.add("李");
        nameList.add("李");
        nameList.add("李");
        List<String>unique=nameList.stream().distinct().collect(Collectors.toList());
        System.out.println(unique.toString());
        System.out.println("stream------foreach");
        List<student> studentss = new ArrayList<>();
        studentss.add(new student("张三", "男", 18, 8801));
        studentss.add(new student("李四", "男", 18, 8802));
        studentss.add(new student("王五", "女", 20, 8803));
        studentss.add(new student("赵六", "女", 20, 8804));
        studentss.add(new student("七七", "女", 21, 8805));
        studentss.stream().forEach(e -> {
            e.setAge(0);
            System.out.println(e.getAge());

        });
    }

    public static void main2(String[] args) {
        int a = 300;
        Integer integer = new Integer(300);
        System.out.println(a==integer);
    }

    public static void main3(String[] args) {
        Integer integer = new Integer(1);
        List<Integer> integer1 = List.of(null);
        System.out.println(integer1);
    }

    public static void main4(String[] args) {
        System.out.println(URLDecoder.decode("https%253A%252F%252Fjiulong.saikul.com%252Fxzimage%252F20221124%252F166928050430010.5.226.226_01_20221124163831106_INTRUSION_DETECTION.jpg%253FX-Amz-Algorithm%253DAWS4-HMAC-SHA256%2526X-Amz-Credential%253Dxz_minio%25252F20221202%25252Fus-east-1%25252Fs3%25252Faws4_request%2526X-Amz-Date%253D20221202T130246Z%2526X-Amz-Expires%253D604800%2526X-Amz-SignedHeaders%253Dhost%2526X-Amz-Signature%253D895f8f0ac4a757e3138c9730c50e0c6524187fbc3137083bf1310f83595b5ff7", StandardCharsets.UTF_8));
    }

    public static void main(String[] args) {
        List<LocalDateTime> list = new ArrayList<>();
        list.add(LocalDateTime.now());
        list.add(LocalDateTime.now());
        list.add(LocalDateTime.now());
        list.add(LocalDateTime.now());
        list.add(LocalDateTime.now());
        System.out.println(list);
        LocalDateTime localDateTime = list.stream().max((o1, o2) -> o1.isAfter(o2) ? 1 : -1).get();
        System.out.println(localDateTime);
    }
}
